package cn.hackcloud.mutithread.mutilthread.timer;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class MyTimer {
	private static Timer timer = new Timer(true);

	static class MyTask extends TimerTask {

		@Override
		public void run() {
			System.out.println("运行了：时间为：" + new Date());
		}

	}

	public static void main(String[] args) throws ParseException {
		MyTask myTask = new MyTask();
		String dateStr = "2019-09-18 17:57:30";
		SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date parse = time.parse(dateStr);
		timer.schedule(myTask, parse);
	}
}
